package view;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

import javax.swing.JPanel;

public class DrawPanel extends JPanel {
	private BufferedImage image;
	private Graphics2D g2d;

	public void paintComponent(final Graphics g) {
		super.paintComponent(g);
		if (image == null) {
			createEmptyImage();
		}
		g.drawImage(image, 0, 0, null);
	}
	
	public void createEmptyImage() {
		image = new BufferedImage(getWidth(), getHeight(),
				BufferedImage.TYPE_INT_ARGB);
		g2d = (Graphics2D) image.getGraphics();
		g2d.setColor(Color.BLACK);
	}
	
	public void clear()
	{
		createEmptyImage();
		repaint();
	}
	
	public Graphics2D getGraphics2D(){
		return g2d;
	}

}
